﻿using IrrlichtLime.Core;

namespace BillardPHS4700 {
    class DiagonalWall {

        public DiagonalWall(float originX, float originY, float vectorX, float vectorY, float nx, float ny) {
            var normal = new Vector2Df(nx, ny);
            normal.Normalize();
            LimitA = new Vector3Df(originX, originY, 0);
            LimitB = LimitA + new Vector3Df(vectorX, vectorY, 0);
            Plane = new Plane3Df(originX, originY, 0, normal.X, normal.Y, 0);
        }

        public Vector3Df LimitA;
        public Vector3Df LimitB;
        public Plane3Df Plane;

        public bool IsBetweenLimits(Vector3Df point) {
            var point0 = new Vector3Df(point.X, point.Y, 0);
            var distAB = (LimitA - LimitB).LengthSQ;
            var distPA = (point0 - LimitA).LengthSQ;
            var distPB = (point0 - LimitB).LengthSQ;
            return distPA <= distAB && distPB <= distAB;
        }
    }
}
